//
//  ListTableViewCell.m
//  盘盈贷1.2
//
//  Created by iOS on 15/3/6.
//  Copyright (c) 2015年 iOS. All rights reserved.
//

#import "ListTableViewCell.h"
#import "THProgressView.h"
#import "THCircularProgressView.h"
#import "List.h"
#define DEFAULT_BLUE [UIColor colorWithRed:0.0 green:122.0/255.0 blue:1.0 alpha:1.0]



@implementation ListTableViewCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
     self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
     if (self) {
      
    self.nameTitle = [[UILabel alloc] init];
    [self.contentView addSubview:self.nameTitle];
         [self.nameTitle release];
    self.yuqinianhua = [[UILabel alloc] init];
    [self.contentView addSubview:self.yuqinianhua];
         [self.yuqinianhua release];
    self.yuqinianhua1 = [[UILabel alloc] init];
    [self.contentView addSubview:self.yuqinianhua1];
         [self.yuqinianhua1 release];
    self.xian = [[UILabel alloc] init];
    [self.contentView addSubview:self.xian];
         [self.xian release];
    self.qi = [[UILabel alloc] init];
    [self.contentView addSubview:self.qi];
         [self.qi release];
    self.gou = [[UILabel alloc] init];
    [self.contentView addSubview:self.gou];
         [self.gou release];
    self.gou1 = [[UILabel alloc] init];
    [self.contentView addSubview:self.gou1];
         [self.gou1 release];
         self.tubiao = [[UIImageView alloc] init];
         [self.contentView addSubview:self.tubiao];
         [self.tubiao release];
         self.imag = [[UIImageView alloc] init];
         [self.contentView addSubview:self.imag];
         [self.imag release];
         self.line = [[UIView alloc] init];
         [self.contentView addSubview:self.line];
         [self.line release];
}

return self;

}



- (void)layoutSubviews
{
    [super layoutSubviews];
    CGFloat width = self.contentView.frame.size.width;
    CGFloat height = self.contentView.frame.size.height;
    self.nameTitle.frame = CGRectMake(width / 2.3, height / 3.1, 250, 27);
    self.nameTitle.center = CGPointMake(width / 2.3, height / 3.1);
    self.nameTitle.font = [UIFont fontWithName:@"Helvetica-Bold" size:14];
    
    self.line.frame = CGRectMake(width / 6.35, height / 2.3, 290, 0.5);
    self.line.center = CGPointMake(width / 6.35, height / 2.3);
    self.line.backgroundColor = [UIColor grayColor];
    self.yuqinianhua.frame = CGRectMake(width / 6.35, height / 1.75, 70, 50);
    self.yuqinianhua.center = CGPointMake(width / 6.35, height / 1.75);
    self.yuqinianhua.text = @"预期年化";
    self.yuqinianhua.font = [UIFont systemFontOfSize:13];
    self.yuqinianhua.textColor = [UIColor grayColor];
    self.yuqinianhua1.frame = CGRectMake(width / 6.35, height / 1.25, 70, 50);
    self.yuqinianhua1.center = CGPointMake(width / 6.35, height / 1.25);
    self.yuqinianhua1.textColor = [UIColor colorWithRed:255 / 255.0  green:102 / 255.0 blue:0/ 255.0 alpha:255];
    self.yuqinianhua1.font = [UIFont fontWithName:@"Helvetica-Bold" size:16];
    self.xian.frame = CGRectMake(width / 2.6, height / 1.75, 30, 50);
    self.xian.center = CGPointMake(width / 2.6, height / 1.75);
    self.xian.font = [UIFont systemFontOfSize:13];
    self.xian.textColor = [UIColor grayColor];
    self.xian.text = @"限";
    self.xian.textColor = [UIColor colorWithRed:255 / 255.0  green:102 / 255.0 blue:0/ 255.0 alpha:255];
    self.qi.frame = CGRectMake(width / 1.85, height / 1.75, 100, 30);
    self.qi.center = CGPointMake(width / 1.85, height / 1.75);
    self.qi.font = [UIFont systemFontOfSize:13];
    self.qi.textColor = [UIColor grayColor];
    //self.qi.backgroundColor = [UIColor redColor];
    self.gou.frame = CGRectMake(width / 2, height / 1.25, 100, 50);
    self.gou.center = CGPointMake(width / 2, height / 1.25);
    self.gou.font = [UIFont systemFontOfSize:13];
    self.gou.textColor = [UIColor grayColor];
    self.gou.text = @"    元起购";
    self.gou1.textAlignment = NSTextAlignmentRight;
    self.gou1.frame = CGRectMake(width / 3.3, height / 1.25, 50, 30);
    self.gou1.center = CGPointMake(width / 3.3, height / 1.25);
    self.gou1.font = [UIFont systemFontOfSize:13];
    self.gou1.textColor = [UIColor colorWithRed:255 / 255.0  green:102 / 255.0 blue:0/ 255.0 alpha:255];
    
    self.rate.frame = CGRectMake(width /1.2, height / 2.5, 9, 9);
    self.rate.textColor = [UIColor redColor];
    
    self.imag.frame = CGRectMake(width / 1.15, height / 4.6, 40, 40);
    self.imag.center = CGPointMake(width / 1.15, height / 4.6);
    
    self.tubiao.frame = CGRectMake(15, 0, 20, 20);
    //self.tubiao.backgroundColor = [UIColor redColor];
    //self.imag.backgroundColor = [UIColor redColor];
    
 //  NSInteger a = [self.bigModel.BidAmount floatValue];
    CGFloat a = [self.bigModel.BidAmount integerValue];
    CGFloat b = [self.bigModel.Amount integerValue];
    CGFloat result = a / b;
    THCircularProgressView *progress = [[THCircularProgressView alloc] initWithCenter:CGPointMake(width / 1.35, height / 1.9  ) radius:width / 9 lineWidth:3 progressMode:THProgressModeFill progressColor:[UIColor redColor] progressBackgroundMode:THProgressBackgroundModeCircumference progressBackgroundColor:[UIColor lightGrayColor] percentage:result];
    progress.centerLabelVisible = YES;
    progress.backgroundColor = [UIColor whiteColor];
   
   
    progress.centerLabel.font = [UIFont systemFontOfSize:18];
    //[progress setPercentage: a / b];
    
    NSLog(@"a:%f", a);
    NSLog(@"b:%f", b);
    CGFloat result1 = result * 100;
   progress.centerLabel.text = [NSString stringWithFormat:@"%.00f%%%", result1];
    // self.percentage = 0;
    [self.contentView addSubview:progress];
    if (result == 100) {
        
         progress.centerLabel.textColor = [UIColor redColor];
        [self.imag setImage:[UIImage imageNamed:@"product_biding.png"]];
        
    }else {
        progress.progressColor = [UIColor grayColor];
        progress.progressBackgroundColor = [UIColor grayColor];
        progress.centerLabel.textColor = [UIColor grayColor];
        [self.imag setImage:[UIImage imageNamed:@"product_complete.png"]];
    }
    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
